import axios from 'axios'
import Vue from 'vue'
import NProgress from 'nprogress'
// import 'nprogress/nprogress.css'

Vue.prototype.axios = axios

const request = axios.create({
  timeout: 30000,
  baseURL: 'https://lianghj.top:8888/api/private/v1/'
})

// request.defaults.headers.post.Authorization = window.localStorage.getItem('token')

request.interceptors.request.use((res, req) => {
  res.headers.Authorization = window.localStorage.getItem('token')
  // 进度条
  NProgress.start()
  return res
}, (err) => {
  return Promise.reject(err)
})

request.interceptors.response.use((res) => {
  NProgress.done()
  return res
})

export default request
